home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / cadel.zip / CADEL.ASM next >
Assembly Source File  |  1990-02-05  |  3KB  |  137 lines

  1.     TITLE    CA_Del
  2.     page    ,132
  3.  
  4. _TEXT      SEGMENT  BYTE PUBLIC 'CODE'
  5.     ASSUME  cs: _TEXT
  6.  
  7.     ORG    100H
  8.  
  9.     public    CA_Del, Vector, Catch, Install
  10.     public    TempA, TempD
  11.  
  12. CA_Del    PROC    FAR
  13.     jmp    Install
  14.  
  15. Catch:    mov    WORD PTR cs:[TempA], ax
  16.     mov    ax, ds
  17.     mov    WORD PTR cs:[TempD], ax
  18.  
  19.     sub    ax,ax            ; Check out keyboard flags
  20.     mov    ds,ax
  21.     mov    al, BYTE PTR ds:[417h]
  22.  
  23. ;    WARNING: trapdoor to unlink CADEL. Press and release (in this order):
  24. ;    Insert, Caps Lock, Num Lock, Scroll Lock
  25. ;    Press and hold:
  26. ;    Left Shift, Right Shift, CTRL, and ALT
  27. ;    (You can let go now)
  28.  
  29.     cmp    al, 0FFh        ; All stati set?
  30.     jnz    Check_CA
  31.  
  32.     mov    ax, WORD PTR cs:[Vector] ; Yes, deinstall our vector
  33.     mov    WORD PTR ds:[9*4], ax
  34.     mov    ax, WORD PTR cs:[Vector + 2]
  35.     mov    WORD PTR ds:[9*4 + 2], ax
  36.     sub    ax, ax
  37.  
  38. Check_CA:
  39.     and    al, 0Ch
  40.     cmp    al, 0Ch            ; Control and alt?
  41.     jz    CheckDel
  42.  
  43.     cmp    al, 04h            ; Control only?
  44.     jnz    GoVect            ; If not, forget it
  45.  
  46.     in    al, 60h            ; Look for control C
  47.     and    al, 7Fh            ; Up or down
  48.     cmp    al, 2Eh
  49.     jz    Eat_It            ; If so, make it vanish
  50.  
  51.     cmp    al, 46h            ; Look for control break
  52.     jz    Eat_It
  53.  
  54.     jnz    GoVect            ; Otherwise let it pass
  55.  
  56. CheckDel:
  57.     in      al,60h            ; read the key
  58.     and    al,7Fh
  59.     cmp    al,53h            ; DEL?
  60.     jnz    GoVect            ; if not, forget it
  61.  
  62. Eat_It:    in    al,61H            ; Get value of keyboard control lines
  63.     mov    ah,al            ; Save it
  64.     or    al,80h            ; Set the "enable kbd" bit
  65.     out    61H,al            ;  and write it out the control port
  66.     xchg    ah,al            ; Fetch original control port value
  67.     out    61H,al            ;  and write it back
  68.     mov    al,20H            ; Send End-Of-Interrupt signal
  69.     out    20H,al            ;  to the 8259 Interrupt Controller
  70.  
  71.     mov    ax, WORD PTR cs:[TempD]
  72.     mov    ds,ax
  73.     mov    ax, WORD PTR cs:[TempA]
  74.     iret
  75.  
  76. GoVect:    mov    ax, WORD PTR cs:[Vector+2]
  77.     push    ax
  78.     mov    ax, WORD PTR cs:[Vector]
  79.     push    ax
  80.     mov    ax, WORD PTR cs:[TempD]
  81.     mov    ds,ax
  82.     mov    ax, WORD PTR cs:[TempA]
  83.     ret                ; (Far return to original vector)
  84.  
  85. TempA:    dw    0
  86. TempD:    dw    0
  87. Vector:    dd    0
  88.  
  89. Install:
  90.     push    cs            ; Establish segment registers
  91.     pop    es
  92.     sub    ax, ax
  93.     mov    ds, ax
  94.     mov    di, OFFSET Vector
  95.     mov    si, 9*4
  96.     movsw                ; Copy the current vector
  97.     movsw
  98.  
  99.     mov    ax,cs            ; Install my cs
  100.     mov    ds:[9*4+2],ax
  101.     mov    ax, OFFSET Catch    ;  and IP
  102.     mov    ds:[9*4], ax
  103.  
  104.     push    cs
  105.     pop    ds
  106.  
  107.     mov    dx, OFFSET CADisabled    ; Tell them what we've done
  108.     mov    ah,9
  109.     int    21h
  110.  
  111.     mov    ax, WORD PTR cs:[2Eh]    ; Free up environment
  112.     mov    es, ax
  113.     mov    ax, 4900H
  114.     int    21h
  115.  
  116.     mov    dx, OFFSET Install    ; Calculate # of paragraphs
  117.     add    dx, 15            ; Minus PSP, round up
  118.     rcr    dx, 1
  119.     sar    dx, 1
  120.     sar    dx, 1
  121.     sar    dx, 1
  122.  
  123.     mov    ax,3100h
  124.     int    21h            ; Terminate and stay resident
  125.     int    20h            ; Just in case
  126.  
  127. CADisabled:
  128.     db    "Control-Alt Del is disabled"
  129.     db    13,10,"$"
  130.  
  131. My_DS:    dw    0
  132.  
  133. CA_Del    ENDP
  134.  
  135. _TEXT    ENDS
  136. END    CA_Del
  137.